Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change pdflib puppeteer #2536

Merged

Conversation

SolidProgramming
Copy link
Contributor

No description provided.

Copy link
Contributor

@tpurschke tpurschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On ubuntu 24.04 I get the following test failure. will test with other OSes

    2024-09-16T09:45:00+02:00 Info - Startup (HtmlToPdfTest.cs in line 18), Downloading headless Browser...
    2024-09-16T09:45:14+02:00 Info - Test Log (HtmlToPdfTest.cs in line 22), starting PDF generation
  
      Failed GeneratePdf [15 s]
      Error Message:
       PuppeteerSharp.ProcessException : Failed to launch browser!
      Stack Trace:
         at PuppeteerSharp.States.ProcessStartingState.StartCoreAsync(LauncherBase p) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:line 83
       at PuppeteerSharp.States.ProcessStartingState.StartCoreAsync(LauncherBase p) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:line 89
       at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:line 72
       at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:line 105
       at FWO.Test.HtmlToPdfTest.GeneratePdf() in /usr/local/fworch/test/csharp/FWO.Test/HtmlToPdfTest.cs:line 26
       at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
       at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
       at NUnit.Framework.Internal.AsyncToSyncAdapter.Await[TResult](Func`1 invoke)
       at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
       at NUnit.Framework.Internal.Commands.TestMethodCommand.RunTestMethod(TestExecutionContext context)
       at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
       at NUnit.Framework.Internal.Commands.BeforeTestCommand.Execute(TestExecutionContext context)
       at NUnit.Framework.Internal.Execution.SimpleWorkItem.<>c__DisplayClass3_0.<PerformWork>b__0()
       at NUnit.Framework.Internal.ContextUtils.<>c__DisplayClass1_0`1.<DoIsolated>b__0(Object _)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location ---
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at NUnit.Framework.Internal.ContextUtils.DoIsolated(ContextCallback callback, Object state)
       at NUnit.Framework.Internal.ContextUtils.DoIsolated[T](Func`1 func)
       at NUnit.Framework.Internal.Execution.SimpleWorkItem.PerformWork()
  
      Standard Output Messages:
     2024-09-16T09:45:00+02:00 Info - Startup (HtmlToPdfTest.cs in line 18), Downloading headless Browser...
     2024-09-16T09:45:14+02:00 Info - Test Log (HtmlToPdfTest.cs in line 22), starting PDF generation
  
  
    2024-09-16T09:45:00+02:00 Info - Startup (LockTest.cs in line 29), Starting Lock Tests...
    2024-09-16T09:45:02+02:00 Debug - TEST_TITLE (LockTest.cs in line 71), TEST_TEXT
  
  
    Failed!  - Failed:     1, Passed:    58, Skipped:     0, Total:    59, Duration: 17 s - FWO.Test.dll (net8.0)
  stdout_lines: <omitted>

@tpurschke tpurschke self-requested a review December 30, 2024 14:45
Copy link
Contributor

@tpurschke tpurschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When doing a fresh install on ubuntu 22.04 I get the expected error during pdf test.
But when trying to generate a PDF in reporting UI, I get the error:

2024-12-30T14:38:53.608356+00:00 ubu22 fworch-ui:   ---
2024-12-30T14:38:53.608370+00:00 ubu22 fworch-ui:  Exception thrown:
2024-12-30T14:38:53.608383+00:00 ubu22 fworch-ui:   WebSocketException
2024-12-30T14:38:53.608396+00:00 ubu22 fworch-ui:  Message:
2024-12-30T14:38:53.608409+00:00 ubu22 fworch-ui:   The remote party closed the WebSocket connection without completing the close handshake.
2024-12-30T14:38:53.608422+00:00 ubu22 fworch-ui:  Stack Trace:
2024-12-30T14:38:53.608436+00:00 ubu22 fworch-ui:   at System.Net.WebSockets.ManagedWebSocket.ThrowEOFUnexpected()
2024-12-30T14:38:53.608452+00:00 ubu22 fworch-ui:     at System.Net.WebSockets.ManagedWebSocket.EnsureBufferContainsAsync(Int32 minimumRequiredBytes, CancellationToken cancellationToken)
2024-12-30T14:38:53.608466+00:00 ubu22 fworch-ui:     at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
2024-12-30T14:38:53.608479+00:00 ubu22 fworch-ui:     at System.Net.WebSockets.ManagedWebSocket.ReceiveAsyncPrivate[TResult](Memory`1 payloadBuffer, CancellationToken cancellationToken)
2024-12-30T14:38:53.608493+00:00 ubu22 fworch-ui:     at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
2024-12-30T14:38:53.608506+00:00 ubu22 fworch-ui:     at System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
2024-12-30T14:38:53.608519+00:00 ubu22 fworch-ui:  --- End of stack trace from previous location ---
2024-12-30T14:38:53.608532+00:00 ubu22 fworch-ui:     at GraphQL.Client.Http.Websocket.GraphQLHttpWebSocket.ReceiveWebsocketMessagesAsync() in /_/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs:line 513
2024-12-30T14:44:28.822372+00:00 ubu22 fworch-ui:  2024-12-30T14:44:28+00:00 Audit - AuthenticateUser (AuthStateProvider.cs in line 38), user admin successfully authenticated
2024-12-30T14:44:38.492313+00:00 ubu22 fworch-ui:  2024-12-30T14:44:38+00:00 Error - Export Report (MainLayout.razor in line 349), User: admin, Role: admin, Unspecified error occured:
2024-12-30T14:44:38.492390+00:00 ubu22 fworch-ui:   ---
2024-12-30T14:44:38.492431+00:00 ubu22 fworch-ui:  Exception thrown:
2024-12-30T14:44:38.492460+00:00 ubu22 fworch-ui:   ProcessException
2024-12-30T14:44:38.492503+00:00 ubu22 fworch-ui:  Message:
2024-12-30T14:44:38.492552+00:00 ubu22 fworch-ui:   Failed to launch browser!
2024-12-30T14:44:38.492589+00:00 ubu22 fworch-ui:  Stack Trace:
2024-12-30T14:44:38.492622+00:00 ubu22 fworch-ui:   at PuppeteerSharp.States.ProcessStartingState.StartCoreAsync(LauncherBase p) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:line 83
2024-12-30T14:44:38.492662+00:00 ubu22 fworch-ui:     at PuppeteerSharp.States.ProcessStartingState.StartCoreAsync(LauncherBase p) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:line 89
2024-12-30T14:44:38.492697+00:00 ubu22 fworch-ui:     at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:line 77
2024-12-30T14:44:38.492736+00:00 ubu22 fworch-ui:     at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:line 110
2024-12-30T14:44:38.492770+00:00 ubu22 fworch-ui:     at FWO.Report.ReportBase.CreatePDFViaPuppeteer(String html, PaperFormat format) in /usr/local/fworch/lib/files/FWO.Report/ReportBase.cs:line 243
2024-12-30T14:44:38.492804+00:00 ubu22 fworch-ui:     at FWO.Report.ReportBase.ToPdf(String html, PaperFormat format) in /usr/local/fworch/lib/files/FWO.Report/ReportBase.cs:line 293
2024-12-30T14:44:38.492838+00:00 ubu22 fworch-ui:     at FWO.Ui.Pages.Reporting.ReportExport.<Export>b__22_0() in /usr/local/fworch/ui/files/FWO.UI/Pages/Reporting/ReportExport.razor:line 175
2024-12-30T14:44:38.494061+00:00 ubu22 fworch-ui:  FWORCHAlert - source: "ui", userId: "3", title: "Export Report", description: "Unclassified error: : Failed to launch browser!  . See log for details!", alertCode: "UiError"

@SolidProgramming
Copy link
Contributor Author

@tpurschke Can you pull with my latest changes to test? This works now for my ubuntu vm.

@tpurschke
Copy link
Contributor

tpurschke commented Dec 30, 2024

@tpurschke Can you pull with my latest changes to test? This works now for my ubuntu vm.

no, same error in my (upgrade) test, which is BTW the same error the pdf test throws.
Could this be caused by missing dependencies or did you/ @alf-cactus already install these during upgrade/install?

For systems like Linux, additional dependencies (e.g., shared libraries required by Chromium) might be missing. Ensure all necessary libraries are installed. Examples include libnss3, libatk-bridge2.0-0, libgbm1, etc.

If not, send me a list of packages (for ubuntu 22.04) and I can test if this helps.

   A total of 1 test files matched the specified pattern.
      Failed GeneratePdf [433 ms]
      Error Message:
       PuppeteerSharp.ProcessException : Failed to launch browser!
      Stack Trace:
         at PuppeteerSharp.States.ProcessStartingState.StartCoreAsync(LauncherBase p) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:line 83
       at PuppeteerSharp.States.ProcessStartingState.StartCoreAsync(LauncherBase p) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/States/ProcessStartingState.cs:line 89
       at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:line 77
       at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Launcher.cs:line 110
       at FWO.Test.HtmlToPdfTest.GeneratePdf() in /usr/local/fworch/test/csharp/FWO.Test/HtmlToPdfTest.cs:line 45
       at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
       at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
       at NUnit.Framework.Internal.AsyncToSyncAdapter.Await[TResult](Func`1 invoke)
       at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
       at NUnit.Framework.Internal.Commands.TestMethodCommand.RunTestMethod(TestExecutionContext context)
       at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
       at NUnit.Framework.Internal.Execution.SimpleWorkItem.<>c__DisplayClass3_0.<PerformWork>b__0()
       at NUnit.Framework.Internal.ContextUtils.<>c__DisplayClass1_0`1.<DoIsolated>b__0(Object _)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location ---
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at NUnit.Framework.Internal.ContextUtils.DoIsolated(ContextCallback callback, Object state)
       at NUnit.Framework.Internal.ContextUtils.DoIsolated[T](Func`1 func)
       at NUnit.Framework.Internal.Execution.SimpleWorkItem.PerformWork()
  
      Standard Output Messages:
     2024-12-30T16:25:49+01:00 Info - Test Log (HtmlToPdfTest.cs in line 25), OS: Unix 5.15.0.130

@tpurschke
Copy link
Contributor

tpurschke commented Dec 30, 2024

after issuing the following command (still ubuntu 22.04), the test as well as the pdf generation within the UI works perfectly:

        sudo apt install -y   ca-certificates   fonts-liberation   libappindicator3-1   libasound2   libatk1.0-0   libatk-bridge2.0-0   libcups2   libdbus-1-3   libdrm2   libgbm1   libglib2.0-0   libnspr4   libnss3   libx11-xcb1   libxcomposite1   libxcursor1   libxdamage1   libxext6   libxfixes3   libxi6   libxrandr2   libxrender1   libxtst6   lsb-release   wget   xdg-utils

This means we need to determine for each supported platform which packages are needed and install them via ansible.

I am confident that we can get this running - so suggest to merge which makes it easier to make the necessary changes in ansible playbooks.

@tpurschke tpurschke marked this pull request as ready for review December 30, 2024 16:59
@tpurschke tpurschke merged commit 40c69e5 into CactuseSecurity:develop Dec 30, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants